<?php
namespace app\superAdmin\controller;
use \think\Controller;
use \think\Db;
use think\Session;

class Index extends Controller{
	public function index()
	{
		Session::clear();
  		return $this->fetch();
	}
	public function login(){
		// $data=input("post.");
		// dump($data);
		$data=[
			'adminname'=>input('adminname'),
			'password'=>md5(input('password'))
			];
			// dump($data);
		$res=Db::name("admins")->where($data)->find();
		if ($res) {
			# code...
			
			 Session::set('adminid',$res["adminid"]);
         Session::set('adminname',$res["adminname"]);
         Session::set('password',$res["password"]);
         $this->redirect('user/index');
		}else{
			$this->error("登陆失败");
		}
	}
	//注销
        public function logout(){
          Session::clear();
          // Cookie::clear("uid");
          // Cookie::clear("uname");
          // Cookie::clear("realname");
          // Cookie::clear("rid");
          $this->redirect('index/index');
    }
}